package cz.anime.ppro.logic;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cz.anime.ppro.model.Event;
import cz.anime.ppro.repositories.EventRepository;

@Component
public class EventComponentImpl implements EventComponent {
	
	@Autowired
	private EventRepository eventRepository;

	@Override
	public Event getEvent(int event) {
		return eventRepository.findOne(event);
	}
	
	@Override
	public List<Event> getEvents() {
		return eventRepository.findAll();
	}
	
	@Override
	public void saveEvent(Event event) {
		eventRepository.saveAndFlush(event);
	}
	
	@Override
	public void deleteEvent(Event event) {
		eventRepository.delete(event);		
	}
}
